package com.cskaoyan.controller.wx.lsj;

import com.cskaoyan.bo.vx.wangdi.GoodsCategoryBo;
import com.cskaoyan.service.wx.lsj.HomeService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.wx.lsj.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  本部分由栗少杰编写 wx/home/index 和/wx/goods/xxx 和一些网页端的一些补充内容在本文件中
 */

@RestController
public class GoodsControllerLi {

    @Autowired
    HomeService homeService;
    @RequestMapping("wx/home/index")
    public BaseRespVo homeindex(){
        HomeIndexVO homeIndexVO = homeService.index();
        return BaseRespVo.ok(homeIndexVO);
    }

    @RequestMapping("wx/goods/count")
    public BaseRespVo count(){
        CountVO count =homeService.count() ;
        return BaseRespVo.ok(count);
    }
    @RequestMapping("wx/goods/category")
    public BaseRespVo category(Integer id){
       GoodsCategoryBo goodsCategoryBo = homeService.category(id);
        return BaseRespVo.ok(goodsCategoryBo);
    }
    @RequestMapping("wx/goods/list")
    public BaseRespVo list(Integer categoryId, Integer page, Integer size,String keyword,String sort,String order){
//        GoodsCategoryBo goodsCategoryBo = homeService.category01(categoryId,page,size,keyword,sort,order);
        ListVO listVO =  homeService.list(categoryId,page,size,keyword,sort,order);
        return BaseRespVo.ok(listVO);
    }

    @RequestMapping("wx/goods/detail")
    public BaseRespVo detail(Integer id){
       GoodsDetailVO goodsDetailVO =  homeService.detail(id);
        return BaseRespVo.ok(goodsDetailVO);
    }

    @RequestMapping("wx/goods/related")
    public BaseRespVo related(Integer id){
        relatedList relatedList = homeService.related(id);
        return BaseRespVo.ok(relatedList);
    }


    @RequestMapping("admin/profile/password")
    public BaseRespVo password(){
        return BaseRespVo.ok();
    }

    @RequestMapping("admin/log/list")
    public BaseRespVo loglist(Integer page, Integer limit, String sort, String order, String name){
        LoglistVO loglistVO =  homeService.loglist(page,limit,sort,order,name);
        return BaseRespVo.ok(loglistVO);
    }
//    退出
    @RequestMapping("admin/auth/logout")
    public BaseRespVo logout(){
        return BaseRespVo.ok();
    }

}
